package cn.tsoft.handler;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.util.Log;

public class HandlerTest01 extends Activity{

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Log.d("System.out","Activity======id："+Thread.currentThread().getId());  
		
		HandlerThread handlerthread =new HandlerThread("handlerThread");
		handlerthread.start();   
        MyHandler handler = new MyHandler(handlerthread.getLooper());   
        Message msg = handler.obtainMessage();   
        /**  
         * 将Message对象发送到目标对象  
         * 所谓的目标对象，就是生成该msg对象的handler对象  
         */  
        msg.sendToTarget();   
	}
	
	
	class MyHandler extends Handler {

		public void handleMessage(Message msg) {
			Log.d("System.out", "handle=====id："
					+ Thread.currentThread().getId());
		}

		public MyHandler() {
		};

		public MyHandler(Looper looper) {
			super(looper);
		}
	}

}
